package judesart.app.config;

import javax.persistence.EntityManagerFactory;

import judesart.common.persistence.AppEngineEntityManagerFactory;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;

@Configuration
public class AppConfig {

    @Bean
    EntityManagerFactory entityManagerFactory() {
        final AppEngineEntityManagerFactory factoryBean = new AppEngineEntityManagerFactory("judesart-pu");
        return factoryBean.entityManagerFactory();
    }

    @Bean
    JpaTransactionManager transactionManager() {
        final JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(entityManagerFactory());
        return transactionManager;
    }

 }
